package com.lanou3g.baidumusic.main.mainfragment;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.lanou3g.baidumusic.R;

import java.util.List;

/**
 * Created by dllo on 17/3/16.
 */

public class MainFragmentAdapter extends FragmentPagerAdapter{

    private List<Fragment> fragments ;
    private String [] titles = {"我的","音乐","动态","发现"} ;

    public MainFragmentAdapter(FragmentManager fm, List<Fragment> fragments) {
        super(fm);
        this.fragments = fragments;
    }


    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    public View getTabView (int index , Context context){

        LayoutInflater layoutInflater = LayoutInflater.from(context);

        View tabView = layoutInflater.inflate(R.layout.view_main_tab , null);


        TextView textView = (TextView) tabView.findViewById(R.id.view_main_tab_tv);


        textView.setText(titles[index]);


        return tabView ;
    }

}
